import { luckysheet } from '../core'
import printJS from 'print-js'
import Store from '../store'
import $ from 'jquery'

/**
 * 打印
 */
export const printSheet = (range: any) => {
  const sheetData = luckysheet.getSheet()
  if(!range) {
    luckysheet.setRangeShow([{
      row: [0, sheetData?.visibledatarow?.length - 1],
      column: [0, sheetData?.visibledatacolumn?.length - 1],
    }])
  }

  const base64 = luckysheet.getScreenshot()
  const sheetName = luckysheet.getSheet()?.name || '未知表格'

  setTimeout(() => {
    printJS({
      printable: base64, //表格的数据
      type: 'image',
      imageStyle: 'margin-bottom:0px;top: 0; position: absolute',
      documentTitle: sheetName
    })
  }, 500)
}
